home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / mui / mui_developer / c / examples / balancing.c < prev    next >
C/C++ Source or Header  |  1997-03-10  |  4KB  |  133 lines

  1. #include "demo.h"
  2.  
  3. int main(int argc,char *argv[])
  4. {
  5.     APTR app,window;
  6.  
  7.     init();
  8.  
  9.     app = ApplicationObject,
  10.         MUIA_Application_Title      , "BalanceDemo",
  11.         MUIA_Application_Version    , "$VER: BalanceDemo 19.5 (12.02.97)",
  12.         MUIA_Application_Copyright  , "©1995, Stefan Stuntz",
  13.         MUIA_Application_Author     , "Stefan Stuntz",
  14.         MUIA_Application_Description, "Show balancing groups",
  15.         MUIA_Application_Base       , "BALANCEDEMO",
  16.  
  17.         SubWindow, window = WindowObject,
  18.             MUIA_Window_Title, "Balancing Groups",
  19.             MUIA_Window_ID   , MAKE_ID('B','A','L','A'),
  20.             MUIA_Window_Width , MUIV_Window_Width_Screen(50),
  21.             MUIA_Window_Height, MUIV_Window_Height_Screen(50),
  22.  
  23.             WindowContents, HGroup,
  24.  
  25.                 Child, VGroup, GroupFrame, MUIA_Weight, 15,
  26.                     Child, RectangleObject, TextFrame, MUIA_Weight,  50, End,
  27.                     Child, RectangleObject, TextFrame, MUIA_Weight, 100, End,
  28.                     Child, BalanceObject, MUIA_CycleChain, 1, End,
  29.                     Child, RectangleObject, TextFrame, MUIA_Weight, 200, End,
  30.                     End,
  31.  
  32.                 Child, BalanceObject, MUIA_CycleChain, 1, End,
  33.  
  34.                 Child, VGroup,
  35.                     Child, HGroup, GroupFrame,
  36.                         Child, RectangleObject, TextFrame, MUIA_ObjectID, 123, End,
  37.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  38.                         Child, RectangleObject, TextFrame, MUIA_ObjectID, 456, End,
  39.                         End,
  40.                     Child, HGroup, GroupFrame,
  41.                         Child, RectangleObject, TextFrame, End,
  42.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  43.                         Child, RectangleObject, TextFrame, End,
  44.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  45.                         Child, RectangleObject, TextFrame, End,
  46.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  47.                         Child, RectangleObject, TextFrame, End,
  48.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  49.                         Child, RectangleObject, TextFrame, End,
  50.                         End,
  51.                     Child, HGroup, GroupFrame,
  52.                         Child, HGroup,
  53.                             Child, RectangleObject, TextFrame, End,
  54.                             Child, BalanceObject, MUIA_CycleChain, 1, End,
  55.                             Child, RectangleObject, TextFrame, End,
  56.                             End,
  57.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  58.                         Child, HGroup,
  59.                             Child, RectangleObject, TextFrame, End,
  60.                             Child, BalanceObject, MUIA_CycleChain, 1, End,
  61.                             Child, RectangleObject, TextFrame, End,
  62.                             End,
  63.                         End,
  64.                     Child, HGroup, GroupFrame,
  65.                         Child, RectangleObject, TextFrame, MUIA_Weight,  50, End,
  66.                         Child, RectangleObject, TextFrame, MUIA_Weight, 100, End,
  67.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  68.                         Child, RectangleObject, TextFrame, MUIA_Weight, 200, End,
  69.                         End,
  70.                     Child, HGroup, GroupFrame,
  71.                         Child, SimpleButton("Also"),
  72.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  73.                         Child, SimpleButton("Try"),
  74.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  75.                         Child, SimpleButton("Sizing"),
  76.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  77.                         Child, SimpleButton("With"),
  78.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  79.                         Child, SimpleButton("Shift"),
  80.                         End,
  81.                     Child, HGroup, GroupFrame,
  82.                         Child, Label("Label 1:"),
  83.                         Child, TextObject, MUIA_Text_Contents, "data...", End,
  84.                         Child, BalanceObject, MUIA_CycleChain, 1, End,
  85.                         Child, Label("Label 2:"),
  86.                         Child, TextObject, MUIA_Text_Contents, "more data...", End,
  87.                         End,
  88.                     End,
  89.                 End,
  90.             End,
  91.  
  92.         End;
  93.  
  94.     if (!app)
  95.         fail(app,"Failed to create Application.");
  96.  
  97.     DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  98.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  99.  
  100.  
  101. /*
  102. ** This is the ideal input loop for an object oriented MUI application.
  103. ** Everything is encapsulated in classes, no return ids need to be used,
  104. ** we just check if the program shall terminate.
  105. ** Note that MUIM_Application_NewInput expects sigs to contain the result
  106. ** from Wait() (or 0). This makes the input loop significantly faster.
  107. */
  108.  
  109.     set(window,MUIA_Window_Open,TRUE);
  110.  
  111.     {
  112.         ULONG sigs = 0;
  113.  
  114.         while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  115.         {
  116.             if (sigs)
  117.             {
  118.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  119.                 if (sigs & SIGBREAKF_CTRL_C) break;
  120.             }
  121.         }
  122.     }
  123.  
  124.     set(window,MUIA_Window_Open,FALSE);
  125.  
  126.  
  127. /*
  128. ** Shut down...
  129. */
  130.  
  131.     fail(app,NULL);
  132. }
  133.